package _2请求转发;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/LoginServlet2")
public class LoginServlet2 extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter pw = resp.getWriter();
		
		
		// 1. 获取用户请求信息
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		
		// 2. 调用service处理
		if("admin".equals(username)&&"123456".equals(password))
		{
			// 3. 打印结果
			resp.sendRedirect("loginOK.html");
		}
		else
		{
			resp.sendRedirect("loginFail.html");
		}
		
		
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}